<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h2>车辆质量投诉列表</h2>

<div>
    <form method="post" action="/veh/list" th:action="@{/veh/list}" >
        品牌:<select name="brandId" id="brandId" class="form-control">
        <option value="0">--请选择--</option>
    </select>
        <button type="submit" class="btn btn-primary"> 查询</button>
        <button type="button" class="btn-add" onclick="fu()">添加投诉</button>
    </form>



</div>

<table border="1">
    <tr>
        <th>投诉编号</th>
        <th>投诉品牌</th>
        <th>投诉问题</th>
        <th>投诉车系</th>
        <th>投诉时间</th>
        <th>投诉状态</th>
        <th>操作</th>
    </tr>
    <tr th:each="abc:${list}">
        <td th:text="${abc.id}"></td>
        <td th:text="${abc.brand.brandName}"></td>
        <td th:text="${abc.problem}"></td>
        <td th:text="${abc.carType}"></td>
        <td th:text="${#dates.format(abc.complaintsTime,'yyyy-MM-dd')}"></td>
        <td th:if="${abc.status==0}">信息审核</td>
        <td th:if="${abc.status==1}">厂家受理</td>
        <td><a th:src="@{modiaf.html}">编辑</a> </td>
    </tr>
</table>
</body>
<script th:src="@{https://code.jquery.com/jquery-3.5.1.min.js}" src="js/jquery.js"></script>
<script  th:inline="javascript">
    $(document).ready(function(){
        $.ajax({
            type:"GET",
            url:"/brand/selectAll",
            dataType:"json",
            success:function(data){
                //获取model中roleId
                var brandId=[[${brandId}]];
                // alert("json："+data);
                for(var i in data){
                    var op="<option ";
                    if(data[i].brandId==brandId){
                        op+=" selected='selected' ";
                    }
                    op+= " value='"+data[i].brandId+"'>"+data[i].brandName+"</option>";
                    $("#brandId").append(op);
                }
            },
            error:function(data){
                alert("对不起，获取数据失败！");
            }
        });
    });
   function fu(){
       location.href="toAdd";
    }
</script>
</html>